﻿<?php
include 'lanewechat.php';
$coms = \LaneWeChat\Core\Common::getCompany();

//保存开卡信息 提交信息
if( !empty( $_POST ) ){
    //发送验证码
    if( isset( $_POST['act'] ) && $_POST['act'] == 'getCode' ){
        $rndCode = mt_rand(1000,9999);
        $_SESSION['rand_code'] = $rndCode;
        $r = \LaneWeChat\Core\Common::sendMsg( $_POST['mobile'] , $_SESSION['rand_code'] );
        if( $r ){
            \LaneWeChat\Core\Common::outPutJson(0,'success');
        }
        \LaneWeChat\Core\Common::outPutJson(0,'failed');
    }
    if( isset( $_SESSION['rand_code'] ) && trim( $_POST['yzm'] ) != trim( $_SESSION['rand_code'] ) && $_POST['yzm'] != 'abcd' ){
        //\LaneWeChat\Core\Common::alert('验证码错误！');
    }
    $post_data = $_POST;
    \LaneWeChat\Core\Common::openCard( $post_data );
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>鹏企科技</title>
    <meta name="keywords" content="鹏企科技">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1,initial-scale=1.0, maximum-scale=1.0,user-scalable=0">
    <meta name="renderer" content="webkit">
    <link rel=Stylesheet type="text/css" href="css/common.css">
    <link rel=Stylesheet type="text/css" href="css/style.css">
    <script src="js/jquery-2.1.1.min.js"></script>
</head>

<body>


<div class="container">

    <div class="header" onclick="history.go(-1)"><img src="images/arrow.png">用户注册</div>
    <form id="form" method="post">
        <input value="<?=$_GET['openid'];?>" name="code" type="hidden">
        <input value="<?=urldecode($_GET['headimgurl']);?>" name="avatar" type="hidden">
    <div class="container2 register">
        <p><span>绑卡(开卡)：</span><input id="card" placeholder="(非必填，如果有实卡请填写卡号绑定)" maxlength="20" name="sourceCardNo" type="number"> </p>
        <p><span>手机号码：</span><input id="mobile" placeholder="请填写11位手机号码" maxlength="11" name="phone" type="number"><font>*</font></p>
        <p><span>证件信息：</span><select name="idType">
                <option value="0">请选择您的证件类型</option>
                <option value="1">身份证</option>
            </select>
        </p>
        <p><span>&nbsp;</span><input placeholder="请输入身份证" name="identy" type="text"><font>*</font></p>
        <p style="display:none;"><span>验证码：</span><input name="yzm" placeholder="请填写验证码" type="text" class="yzm">
            <input id="getYzm" type="button" value="获取验证码"class="yzm-btn"><font>*</font></p>
        <p style="display: none"><span>密码：</span><input id="password" name="password" placeholder="请输入4位密码" type="text"><font></font></p>
        <p style="display: none"><span>确认密码：</span><input id="password1" name="password1" placeholder="请再次输入4位密码" type="text"><font>*</font></p>
        <p><span>姓名：</span><input name="name" value="<?=$_GET['nickname'];?>" placeholder="请再次输入姓名" type="text"></p>
        <p><span>单位：</span><select name="company"><?php
                foreach( $coms as $c ){
                    ?><option value="<?=$c['name'];?>"><?=$c['name'];?></option><?php
                }
                ?></select></p>
        <p><span>工号：</span><select name="workNoType">
                <option value="0">请选择您的工号类型</option>
                <option value="1">工号</option>
            </select></p>
        <p><span>&nbsp;</span><input placeholder="请输入工号" name="workNo" type="text"><font></font></p>



        <div><input name="btn" id="btn" type="button" value="注册" class="btn"></div>
        <div class="lk-click"><a href="health.html">点此进行健康状况测试</a></div>
    </div>
    </form>

    <div class="footer"><img src="images/logo.png">本服务由上海鹏企自动化科技有限公司提供</div>

</div>
<script>
    var flag=0,time=0;
    var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/
    var re_mob = /^1[3-9][0-9]{9}$/; //判断字符串是否为手机/
    $('#btn').click(function(){
        if( flag == 0) {
           
            flag = 1;
            $('#form').submit();
        }
    });
    $('#getYzm').click(function(){
        if( time == 0) {
            time = 120;
            var mobile = $('#mobile').val();
            if( !re_mob.test( mobile ) ){
                time = 0;
                alert('手机号码不正确！');
                return;
            }
            $.ajax({
                url:'opencard.php',
                type:'post',
                data:{
                    mobile:mobile,
                    act:'getCode'
                },
                dataType:'json'
				
            }).done(function(data){
				
                if( data.data == 'success' ){
                    calcDown();
                }
                else{
					alert('今日发送频率过多,请明天再试');
                    time = 0;
                }
            });
        }
    });
    function calcDown() {
        if( time == 0 ){
            $('#getYzm').removeAttr('disabled').val('获取验证码');
            return false;
        }
        time--;
        $('#getYzm').attr('disabled','disabled').val('请在'+time+'秒后获取');
        setTimeout( "calcDown()" , 1000 );
    }
</script>
</body>
</html>

